<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>支付结果页面</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="icon" href="/photo/Profile picture/log.ico" type="image/x-icon">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            position: relative;
            overflow: hidden;
        }

        /* 云纹背景效果 */
        body::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background:
                radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 2%),
                radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 2%),
                radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 2%);
            background-size: 300px 300px;
            z-index: 0;
        }

        .container {
            position: relative;
            z-index: 2;
            max-width: 800px;
            width: 100%;
            text-align: center;
        }

        .tabs {
            display: flex;
            justify-content: center;
            margin-bottom: 30px;
            gap: 20px;
        }

        .tab-btn {
            background: rgba(255, 255, 255, 0.15);
            border: 2px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 12px 30px;
            font-size: 18px;
            font-weight: 600;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            backdrop-filter: blur(5px);
        }

        .tab-btn:hover {
            background: rgba(255, 255, 255, 0.25);
        }

        .tab-btn.active {
            background: rgba(255, 255, 255, 0.3);
            border-color: white;
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
        }

        .result-card {
            background: rgba(255, 255, 255, 0.12);
            border-radius: 25px;
            padding: 50px 30px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(12px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            transition: all 0.5s ease;
        }

        .result-icon {
            width: 150px;
            height: 150px;
            margin: 0 auto 30px;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 50%;
            font-size: 70px;
            animation: pulse 2s infinite;
        }

        .success .result-icon {
            background: rgba(46, 204, 113, 0.2);
            border: 5px solid rgba(46, 204, 113, 0.4);
            color: #2ecc71;
        }

        .failure .result-icon {
            background: rgba(231, 76, 60, 0.2);
            border: 5px solid rgba(231, 76, 60, 0.4);
            color: #e74c3c;
        }

        .result-title {
            font-size: 42px;
            font-weight: 700;
            margin-bottom: 20px;
            color: white;
            text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        }

        .success .result-title {
            color: #2ecc71;
        }

        .failure .result-title {
            color: #e74c3c;
        }

        .result-message {
            font-size: 20px;
            color: rgba(255, 255, 255, 0.9);
            margin-bottom: 30px;
            line-height: 1.6;
            max-width: 600px;
            margin-left: auto;
            margin-right: auto;
        }

        .order-details {
            background: rgba(0, 0, 0, 0.15);
            border-radius: 15px;
            padding: 25px;
            margin: 30px auto;
            max-width: 500px;
            text-align: left;
        }

        .detail-item {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            color: rgba(255, 255, 255, 0.85);
            font-size: 17px;
        }

        .detail-item:last-child {
            border-bottom: none;
        }

        .detail-label {
            font-weight: 500;
        }

        .detail-value {
            font-weight: 600;
        }

        .action-buttons {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-top: 30px;
            flex-wrap: wrap;
        }

        .btn {
            padding: 15px 35px;
            border-radius: 50px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .primary-btn {
            background: linear-gradient(to right, #2ecc71, #27ae60);
            color: white;
            box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
        }

        .secondary-btn {
            background: rgba(255, 255, 255, 0.15);
            color: white;
            border: 1px solid rgba(255, 255, 255, 0.3);
        }

        .btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
        }

        .primary-btn:hover {
            background: linear-gradient(to right, #27ae60, #219653);
        }

        .secondary-btn:hover {
            background: rgba(255, 255, 255, 0.25);
        }

        /* 动画效果 */
        @keyframes gradientBG {
            0% {
                background-position: 0% 50%;
            }

            50% {
                background-position: 100% 50%;
            }

            100% {
                background-position: 0% 50%;
            }
        }

        @keyframes pulse {
            0% {
                transform: scale(0.95);
                box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.5);
            }

            70% {
                transform: scale(1);
                box-shadow: 0 0 0 20px rgba(46, 204, 113, 0);
            }

            100% {
                transform: scale(0.95);
                box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
            }
        }

        .failure .result-icon {
            animation: shake 0.8s cubic-bezier(.36, .07, .19, .97) both;
        }

        @keyframes shake {

            10%,
            90% {
                transform: translateX(-1px);
            }

            20%,
            80% {
                transform: translateX(2px);
            }

            30%,
            50%,
            70% {
                transform: translateX(-4px);
            }

            40%,
            60% {
                transform: translateX(4px);
            }
        }

        .hidden {
            display: none;
        }

        @media (max-width: 600px) {
            .result-title {
                font-size: 32px;
            }

            .result-message {
                font-size: 18px;
            }

            .result-icon {
                width: 120px;
                height: 120px;
                font-size: 50px;
            }

            .btn {
                padding: 12px 25px;
                font-size: 16px;
            }

            .tabs {
                flex-direction: column;
                align-items: center;
            }

            .tab-btn {
                width: 100%;
                max-width: 300px;
            }
        }
    </style>
</head>

<body>
    <div class="container" id="app">

        <!-- 支付成功页面 -->
        <div id="success-result" class="result-card success">
            <div class="result-icon">
                <i class="fas fa-check"></i>
            </div>
            <h1 class="result-title">支付成功！</h1>
            <p class="result-message">
                您的订单已支付成功，感谢您的购买！商品将在3-5个工作日内发货，您可以在订单页面查看物流信息。
            </p>

            <div class="order-details">
                <div class="detail-item">
                    <span class="detail-label">订单编号：</span>
                    <span class="detail-value">{{order.orderId}}</span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">支付金额：</span>
                    <span class="detail-value">￥ {{order.payMoney}}</span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">支付方式：</span>
                    <span class="detail-value">支付宝</span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">支付时间：</span>
                    <span class="detail-value">{{order.payTime}}</span>
                </div>
            </div>

            <div class="action-buttons">
                <button class="btn primary-btn" @click="viewOrderDetail">
                    <i class="fas fa-shopping-bag"></i> 查看订单
                </button>
                <button class="btn secondary-btn" @click="viewIndexDetail">
                    <i class="fas fa-home"></i> 返回首页
                </button>

            </div>
        </div>

    </div>
    <script src="/js/jquery-1.12.4.min.js"></script>
    <script src="/js/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                order: {}
            },
            methods: {
                getOrder() {
                    const orderId = new URLSearchParams(window.location.search).get('out_trade_no');
                    if (!orderId) {
                        alert('订单编号不能为空');
                        return;
                    }

                    $.ajax({
                        url: `http://localhost:8080/order/findOrderById?orderId=${orderId}`,
                        method: 'GET',
                        headers: { 'token': `${localStorage.getItem('token') || ''}` },
                        success: (response) => {
                            if (response.code === 200) {
                                this.order = response.data;
                                this.order.payMoney = this.order.commodityList.reduce((sum, item) => sum + item.commoditySalePrice * item.commodityNum, 0)
                                    .toFixed(2);
                                console.log('计算后的支付金额:', this.order.payMoney);

                            } else {
                                alert('获取订单信息失败，请稍后再试。');
                            }
                        },
                        error: (error) => {
                            console.error('获取订单信息失败:', error);
                            alert('获取订单信息失败，请稍后再试。');
                        }
                    });
                },
                viewOrderDetail() {
                    // 获取当前订单 ID 并跳转
                    const orderId = this.order.orderId;
                    if (!orderId) {
                        alert('订单编号不存在');
                        return;
                    }

                    // 跳转到订单详情页并带上订单号
                    window.location.href = `/order.html?orderId=${orderId}`;
                },
                viewIndexDetail(){
                    // 跳转到首页
                    window.location.href = '/index-ai.html';
                }
            },
            created() {
                this.getOrder();
            }
        })

    </script>
</body>

</html>